const TopicCategory = require("../../models/topicCategory");

//新增一条数据
exports.addCategory = async function(category){
    return TopicCategory.create({
        ...category
    })
}

//更新一条数据
exports.updateCategory = async function(id,category){
    delete category.id;
    return TopicCategory.update(
        {...category},
        {where: {id: id}, individualHooks: true}
    )
}

//删除一条数据
exports.deleteCategory = async function(id){
    return TopicCategory.destroy({
        where:{id},
        individualHooks:true
    })
}

//获取活动列表
exports.getCategoryList = async function(){
    return TopicCategory.findAll({
        attributes:['id','sort','name'],
        order:[['sort','ASC']]
    });
}